/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.gob.pnp.beans;

import java.io.Serializable;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author mvalentin
 */
public class LoginForm extends org.apache.struts.action.ActionForm  implements Serializable{
    
    private String usuario;
    private String password;

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsuario() {
        return usuario;
    }

    public void setUsuario(String usuario) {
        this.usuario = usuario;
    }

    /**
     *
     */
    public LoginForm() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if (this.getUsuario() == null || this.getUsuario().length() < 1) {
            errors.add("user", new ActionMessage("error.usuario"));
        }
        if(this.getPassword()==null || this.getPassword().length() < 1){
            errors.add("pwd", new ActionMessage("error.password"));
        }
        return errors;
    }
}
